#ifndef DIMENSIONS_H
#define DIMENSIONS_H

#include <boost/container/vector.hpp>
#   include <caspp/config.h>
#   include "basics.h"

CASPP_NS_BEGIN

class Dimension: public UpgradeLockable {
public:
    typedef Dimension __self;
    typedef UpgradeLockable __super;
    typedef boost::shared_lock<__self> Locker;
    typedef int16_t Unit;
    typedef uint16_t Index;
    enum {
        Size = 8,
        Min=INT16_MIN,
        Max=INT16_MAX,
        IndexMax=INT16_MAX
    };

private:
    Unit Us_m[Size];
    static boost::container::vector<Dimension> cachedDimensions_s;
public:
    Dimension(const Dimension & __x);
    Dimension(Unit mass,
              Unit position,
              Unit time,
              Unit charge,
              Unit temperature,
              Unit intensity,
              Unit angle,
              Unit other);
    const Dimension operator * (const Dimension & __x);
    const Dimension operator / (const Dimension & __x);
    bool operator == (const Dimension & __x);
    Index index();
private:
    Dimension();
    Index index(Locker &locker);
    Dimension operator + (const Dimension & __x);
    Dimension operator - (const Dimension & __x);
};

CASPP_NS_END

#endif // DIMENSIONS_H
